<template>

    <el-row>
        <el-col :span="24">
            <el-table :data="costList" 
		          stripe 
				  border
                  show-summary
                  :summary-method="getSummaries"
				  @selection-change="handleSelectionChange">
                    <el-table-column type="index" width="50" />
                    <el-table-column prop="costname" label="项目名称" width="180" />
                    <el-table-column prop="costtype" label="项目类型" width="100"/>
                    <el-table-column prop="costprice" label="价格" width="100"/>
                    <el-table-column prop="number" label="数量" width="80"/>
                    <el-table-column prop="createtime" label="创建时间"/>
                    <el-table-column label="状态" width="100">
                        <template #default="{row}">
                            <span style="color:green" v-if="row.state==0">未支付</span>
                            <span style="color:red" v-else-if="row.state==1">已支付</span>
                        </template>
                    </el-table-column>
		</el-table>
        </el-col>
    </el-row>

</template>

<script setup>
import httpRequest from '@/common';
import { ElMessage } from 'element-plus';
import {ref,getCurrentInstance, onMounted,defineProps, watch, computed} from 'vue';
import store from '@/store';

const {proxy} = getCurrentInstance();

//获取父组件传递的registerId  挂号id
const props = defineProps({
    rid:{
        type: Number,
        required: true
    }
});

const registerId = ref(null);

const costList = ref([]);

//查询需要进行的检查  状态是已缴费的
const getCostByRid = ()=>{



    httpRequest(
        proxy,
        'post',
        '/cost/conditions',
        {
            registerId: registerId.value
        },
        resultBean=>{
            costList.value = resultBean.data;
        }
    )
}

const getSummaries = (data)=>{
    console.log('--------getSummaries---------',data);
}

const activeTab = computed(()=>{
    return store.state.mrActiveTab;
})

watch(activeTab,(newValue,oldValue)=>{
    console.log('--------标签页切换了-------------------',newValue);
    if(newValue=='searchfee'){
        registerId.value = props.rid;
        getCostByRid();
    }
},{
    immediate: true 
})

</script>

<style>
</style>